import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextPane;

/**
 * 
 */

/**
 * @author Enzo
 *
 *
 * Singleton Setup
 * 	We only want one debug frame, make sure it doesn't create a new frame
 *  for every new debug message
 *
 */
public class DebugFrame extends JFrame{
	static boolean isInstantiated = false;
	static private JFrame debugFrame;
	static private JTextArea debugPane = new JTextArea();
	
	//Default Constructor
	public DebugFrame(){
		if(!isInstantiated){
			isInstantiated = true;
			
			//Initialize the GUI interface 
			//Schedule a job for the event-dispatching thread:
	        //creating and showing this application's GUI.
	        javax.swing.SwingUtilities.invokeLater(new Runnable() {
	            public void run() {
	            	createFrame();
	            }
	        });
		}else{
			//System.out.println("ErrorFrame already created");
		}
	}
	
	private void createFrame(){
		debugFrame = new JFrame("DebugFrame");
		debugFrame.setSize(500, 300);
		
		//Set up the text
		JScrollPane scrollPane = new JScrollPane(debugPane);
		debugFrame.add(scrollPane);
		
		debugFrame.validate();
		debugFrame.setVisible(true);
	}
	/**
	 * Used to display debug messages on the GUI side of things
	 * Just make sure it's set to VERBOSE in the MainFrameGUI
	 * 
	 * @param message
	 */
	public void displayMessage(String message){
		//System.out.println("DISPLAY MESSAGE: " +message);
		debugPane.append("\n" +message);
	}
}
